<template>
	<view>
		<swiper class="swiper-banner" :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000" circular
			:style="getStyle">
			<swiper-item v-for="(swiper,s) in swipers" :key="s">
				<view class="swiper-item">
					<image :src="swiper.src" mode="" :style="getStyle" @click="previewImage(s)"></image>
				</view>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	export default {
		name: "swiper-banner",
		data() {
			return {

			};
		},
		props: {
			swipers: {
				type: Object | Array
			},
			height: {
				type: String
			},
			bool:{
				type:Boolean
			}
		},
		computed: {
			getStyle() {
				if (this.height) {
					return `height:${this.height}rpx`
				}
			},
			getUrls(){
				if(this.bool){
					return this.swipers.map(item=>{
						return item.src
					})
				}
			}
		},
		methods:{
			previewImage(index) {
				// 预览图片
				uni.previewImage({
					urls: this.getUrls,
					current:index,
					loop:true,
				});
			}
		}
	}
</script>

<style scoped>
	.swiper-banner {
		width: 750rpx;
		height: 350rpx;
	}

	.swiper-banner .swiper-item image {
		width: 750rpx;
		height: 350rpx;
	}
</style>